"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""


class TenXClass:
    def __init__(self):
        self.name = "冯俊霆"
        self.id = "3124002006"

    @staticmethod
    def question1(n: int) -> list[str]:
        print(n)  # 打印，防止IDE警告
        numbers = []
        k = 1
        numbers.append(str(k))
        while len(numbers) < n:
            k += 1
            i = 0
            while i < len(str(k)):
                if int(str(k)[i]) == 4:
                    k = str(k)
                    if i == 0:
                        k = k.replace('4', '10')
                        k = int(k)
                        continue
                    k = k.replace('4', '0')
                    k = int(k)
                    k = k + 10 ** (len(str(k)) - i)
                    i = 0
                else:
                    i += 1
            numbers.append(str(k))
        return numbers

    @staticmethod
    def question2() -> tuple[int, int, int]:
        programs = []
        program = ()
        for x in range(0, 101):
            for y in range(0, 101):
                for z in range(0, 101):
                    if 5 * x + 3 * y + z == 100 and x + y + 3 * z == 100:
                        program = (x, y, 3 * z)
                        programs.append(program)
                        pass
        return programs

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        equipments = []
        props = []
        materials = []
        divided_items = {"equipment": equipments, "prop": props, "material": materials}
        for i in range(0, len(items)):
            if items[i] in equipment:
                equipments.append(items[i])
            if items[i] in prop:
                props.append(items[i])
            if items[i] in material:
                materials.append(items[i])
        return divided_items

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        print(item_values, items)  # 打印，防止IDE警告
        program = []
        program_value = 0
        cnt = 3
        ranked_items = []
        i = 0
        break1 = 0
        more_expensive_one = items[i]
        items2 = items[:]
        item_values2 = {}
        while len(ranked_items) < len(item_values):
            more_expensive_one = items2[i]
            for i in range(0, len(items2)):
                if item_values[items2[i]] > item_values[more_expensive_one]:
                    more_expensive_one = items2[i]
                if i == len(items2) - 1:
                    ranked_items.append(more_expensive_one)
                    item_values2[more_expensive_one] = item_values[more_expensive_one]
                    del item_values[more_expensive_one]
                    while more_expensive_one in items2:
                        items2.remove(more_expensive_one)
                    i = 0
                if len(ranked_items) == len(items) or len(items2) == 0:
                    break1 = 1
                    break
            if break1:
                break
        while i < len(ranked_items):
            if items:
                if cnt != 0:
                    if ranked_items[i] in items:
                        items.remove(ranked_items[i])
                        cnt -= 1
                        program.append(ranked_items[i])
                        program_value += item_values2[ranked_items[i]]
                        i = 0
                    else:
                        i += 1
                else:
                    break
            else:
                break
        answer = (program, program_value)
        return answer

    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        print(matrix)  # 打印，防止IDE警告
        points = []
        for i in range(0, len(matrix)):
            for j in range(0, len(matrix[i])):
                if matrix[i][j] == 0:
                    point = (i + 1, j + 1)
                    points.append(point)
        return points
